#include "Comm.hpp"
#include "Fifo.hpp"
#include <unistd.h>

int main()
{
    // 1.生成key
    key_t key = GetKey();
    cout << "key sucess,key:" << key << endl;

    // 2.获取shmid
    int shmid = GetShmid(key, defaultsize);
    cout << "shmid sucess,shmid:" << shmid << endl;
    // 4. 将共享内存和进程进行挂接(关联)
    char *addr = (char *)AttchShm(shmid);

    // 0.引入管道
    Sync syn;
    syn.OpenWrite();

    // 可以进行通信了
    for (char c = 'A'; c <= 'Z'; c++) // pipe, fifo, ->read/write->系统调用， shm -> 没有使用系统调用！！
    {
        addr[c - 'A'] = c;
        sleep(1);
        syn.Wakeup();
    }

    sleep(10);
    // llast 去关联
    DeAttchShm(addr);
    return 0;
}